package cn.com.fuhuitong.main.mine.adapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import cn.com.fuhuitong.R
import cn.com.fuhuitong.app.BASE_HTTP_URL
import cn.com.fuhuitong.app.getImageUrl
import cn.com.fuhuitong.base.BaseDelegateAdapter
import cn.com.fuhuitong.main.ItemViewType
import cn.com.fuhuitong.main.mine.entity.CollectionListEntity
import cn.com.fuhuitong.utils.SpanUtils
import com.alibaba.android.vlayout.LayoutHelper
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.item_collection_goods.view.*

class CollectionListAdapter(
    private val mContext: Context, private val mHelper: LayoutHelper
) : BaseDelegateAdapter<CollectionListEntity>(
    mContext = mContext,
    mHelper = mHelper,
    mLayoutId = R.layout.item_collection_goods,
    mItemViewType = ItemViewType.COLLECTION_LIST
) {

    init {
        addChildClickViewIds(R.id.text_collection_goods_delete)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(itemView: View, position: Int, itemData: CollectionListEntity) {
        super.onBindViewHolder(itemView, position, itemData)
        Glide.with(itemView).load(getImageUrl(itemData.image))
            .into(itemView.image_collection_goods_icon)
        itemView.text_collection_goods_name.text = itemData.title
        itemView.text_collection_goods_price.text =
            SpanUtils.setMoneyStyle(itemData.price.toDouble())
    }
}